<%@ page language="java" import="java.util.*" pageEncoding="UTF-8" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
            + path + "/";
    String id = (String) session.getAttribute("id");
    Integer datastatus = (Integer) session.getAttribute("datastatus");
    Integer totlenum = (Integer) session.getAttribute("totlenum");
    Integer curPage = (Integer) session.getAttribute("curPage");
    String username = (String) session.getAttribute("username");
    String shopid = (String) session.getAttribute("shopid");
    String parentid = (String) session.getAttribute("parentid");
    Integer adminUsergrade = (Integer) session.getAttribute("adminUsergrade");
    String freeroute = (String) session.getAttribute("freeroute");
%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <!-- Meta, title, CSS, favicons, etc. -->
    <meta charset="utf-8">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <title>随便打TCS系统</title>
    <script type="text/javascript" src="<%=basePath%>js/initPage.js"></script>
    <!-- Bootstrap -->
    <link href="<%=basePath%>vendors/bootstrap/dist/css/bootstrap.min.css"
          rel="stylesheet">
    <!-- Font Awesome -->
    <link
            href="//netdna.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css"
            rel="stylesheet">
    <!-- NProgress -->
    <link href="<%=basePath%>vendors/nprogress/nprogress.css"
          rel="stylesheet">
    <!-- iCheck -->
    <link href="<%=basePath%>vendors/iCheck/skins/flat/green.css"
          rel="stylesheet">

    <!-- bootstrap-progressbar -->
    <link
            href="<%=basePath%>vendors/bootstrap-progressbar/css/bootstrap-progressbar-3.3.4.min.css"
            rel="stylesheet">
    <!-- JQVMap -->
    <link href="<%=basePath%>vendors/jqvmap/dist/jqvmap.min.css"
          rel="stylesheet"/>
    <!-- bootstrap-daterangepicker -->
    <link
            href="<%=basePath%>vendors/bootstrap-daterangepicker/daterangepicker.css"
            rel="stylesheet">

    <!-- Custom Theme Style -->
    <link href="<%=basePath%>build/css/custom.min.css" rel="stylesheet">
    <%--<link rel="stylesheet" href="<%=basePath%>css/bootstrap.min.css">--%>
    <link rel="stylesheet" type="text/css" href="http://www.jq22.com/jquery/font-awesome.4.6.0.css">
    <link rel="stylesheet" href="<%=basePath%>css/tree.css">

    <style>
        .f-tree {
            display: none;
            background: #fff;
            position: absolute;
            z-index: 9999;
            padding: 10px 0 30px;
            left: 0;
            top: 0;
            width: 100%;
            max-height: 750px;
            overflow-y: scroll;
        }

        .treeBox {
            position: fixed;
            top: 0;
            left: 0;
            width: 100vw;
            height: 100vh;
            display: none;
            background-color: #333;
            opacity: .4;
            z-index: 9998;
        }

        .tree_title {
            border-bottom: 1px solid #ccc;
            padding: 10px 0 10px 16px;
            margin-bottom: 10px;
            position: relative;
        }

        .tree_title .close {
            position: absolute;
            right: 10px;
            top: 0;
        }

        .tree_title .close i {
            font-size: 24px;
            color: #333;
        }
    </style>
    <style>
        .fa-minus-square-o:before {
            color: #ff9800
        }

        .fa-file-text-o:before {
            color: #009688
        }

        .ttRes {
            margin: 0 0 0 35px;
            color: #009688;
        }

        #default_tree ul:first-child {
            padding: 0
        }

        .treeList {
            padding-left: 20px;
        }

        .treeList i {
            margin: 0 5px;
        }

    </style>
</head>

<body class="nav-md">
<div class="container body">


    <div id="xiugaidiv" class="white_content_small">
        <div style="text-align: right; cursor: default; height: 40px;">
            <span style="font-size: 16px;" onclick="CloseDiv('xiugaidiv','fade')">关闭</span>
        </div>
        <div class="item form-group">
            所属商家<input id="changeshopid"
                       class="form-control col-md-7 col-xs-12" name="changeshopid"
                       placeholder="" type="text" value="">
        </div>
        <!-- <div class="item form-group">
				费率 <select class="form-control" id="freeroute"
					class="form-control col-md-7 col-xs-12">
					<option value="" selected="selected">请选择修改的费率</option>
					<c:forEach items="${freeroutes}" var="s" varStatus="z">
						<option value="${s.name}">${s.name}</option>
					</c:forEach>
				</select>
			</div> -->
        <div class="form-group">
            <div class="col-md-6 col-md-offset-3">
                <a type="submit" class="btn btn-primary" href="javascript:void(0)"
                   onclick="CloseDiv('xiugaidiv','fade')">取消</a> <a id="dialog"
                                                                    type="submit" class="btn btn-success"
                                                                    href="javascript:void(0)"
                                                                    onclick="xiugaiall() ">批量修改</a>
            </div>
        </div>
    </div>

    <div id="daorudiv" class="white_content_small">
        <div style="text-align: right; cursor: default; height: 40px;">
            <span style="font-size: 16px;" onclick="CloseDiv('daorudiv','fade')">关闭</span>
        </div>
        <div class="form-group">
            <div class="col-md-6 col-md-offset-3">
                <a type="submit" class="btn btn-primary" href="javascript:void(0)"
                   onclick="CloseDiv('daorudiv','fade')">取消</a> <a id="upload"
                                                                   type="submit" class="btn btn-success"
                                                                   href="javascript:void(0)"
                                                                   onclick="addressBookExport()">检索并导出</a>
            </div>
        </div>
    </div>
    <div class="main_container">
        <div class="col-md-3 left_col">
            <div class="left_col scroll-view">


                <div class="clearfix"></div>


                <br/>


            </div>
        </div>


        <!-- page content -->
        <div class="right_col" role="main">
            <div class="">
                <div class="page-title">
                    <div class="title_left"></div>
                    <div class="x_content">
                        <button type="submit" class="btn btn-default"
                                onclick="selectOEM('${curPage}')">刷新
                        </button>

                        <a>共计${totlenum}用户</a>
                    </div>
                </div>

                <div class="x_panel" style="position: relative;">
                    <div class="treeBox">
                    </div>
                    <div class="f-tree">
                        <div class="tree_title">查看下级
                            <div class="close" onclick="closeBtn()"><i class="fa fa-times"></i></div>
                        </div>
                        <div id="default_tree" class="col-sm-4">
                        </div>
                    </div>
                    <div class="x_content">
                        <table id="datatable" class="table table-striped table-bordered">
                            <thead>
                            <tr>
                                <th><input type="checkbox" id="checkall" name="checkall" onclick="checkAll()"/>全选</th>
                                <th>昵称</th>
                                    <th>手机号</th>
                                <th>成为代理时间</th>
                                    <th>操作</th>
                            </tr>
                            </thead>


                            <tbody>
                            <c:forEach items="${list}" var="s" varStatus="z">

                                <tr>
                                    <td><input type="checkbox" value="${s.id}" id="check" name="check"/></td>
                                    <td><c:if test="${s.username == null }">
                                        <span>未设置昵称</span>
                                    </c:if> <c:if test="${s.username != null }">
                                        <span>${s.mobile}</span>
                                    </c:if></td>
                                    <td><c:if test="${s.mobile == null }">
                                        <span>未设置手机号</span>
                                    </c:if> <c:if test="${s.mobile != null }">
                                        <span>${s.mobile}</span>
                                    </c:if></td>
                                    <td><c:if test="${s.mobile == null }">
                                        <span>---</span>
                                    </c:if> <c:if test="${s.mobile != null }">
                                        <span>${s.createTime}</span>
                                    </c:if></td>
                                        <td><c:if test="${s.datastatus == true }">
                                            <button type="submit" class="btn btn-danger"
                                                    id="datastate" onclick="dongjie('${s.id}','${s.mobile}')">冻结
                                            </button>
                                        </c:if> <c:if test="${s.datastatus == false }">
                                            <button type="submit" class="btn btn-success"
                                                    id="datastate" onclick="jiedong('${s.id}','${s.mobile}')">解冻
                                            </button>
                                        </c:if>
                                            <a href="javascript:" type="submit" class="btn btn-success"
                                               onclick="selectNextUsers('${s.id}')">下级账户</a>

                                        </td>
                                </tr>

                            </c:forEach>
                            </tbody>
                        </table>
                    </div>
                </div>
                <div class="clearfix"></div>
                <br/>
            </div>
            <div style="width: 100%; text-align: center;">
                <div id='page'></div>
            </div>
        </div>
        <!-- /page content -->


    </div>
</div>

<script>
    /**
     * 纯粹的JS分页插件，代码缺点：JS操作DOM冗余太多，太繁琐
     */
    pageUtil.initPage('page', {
        totalCount: ${totlenum}, //总页数，一般从回调函数中获取。如果没有数据则默认为1页
        curPage: ${curPage}, //初始化时的默认选中页，默认第一页。如果所填范围溢出或者非数字或者数字字符串，则默认第一页
        showCount: 9, //分页栏显示的数量
        pageSizeList: [10], //自定义分页数，默认[5,10,15,20,50]
        defaultPageSize: 10, //默认选中的分页数,默认选中第一个。如果未匹配到数组或者默认数组中，则也为第一个
        isJump: true, //是否包含跳转功能，默认false
        isPageNum: true, //是否显示分页下拉选择，默认false
        isPN: true, //是否显示上一页和下一面，默认true
        isFL: true, //是否显示首页和末页，默认true
        jump: function (curPage, pageSize) { //跳转功能回调，传递回来2个参数，当前页和每页大小。如果没有设置分页下拉，则第二个参数永远为0。这里的this被指定为一个空对象，如果回调中需用到this请自行使用bind方法
            selectOEM(curPage);
        },
    });
</script>

<style>
    .black_overlay {
        display: none;
        position: absolute;
        top: 0%;
        left: 0%;
        width: 100%;
        height: 100%;
        background-color: black;
        z-index: 1001;
        -moz-opacity: 0.8;
        opacity: .80;
        filter: alpha(opacity=80);
    }

    .white_content {
        display: none;
        position: absolute;
        top: 20%;
        left: 30%;
        width: 60%;
        height: 60%;
        border: 16px solid white;
        background-color: white;
        z-index: 1002;
        overflow: auto;
        left: 30%;
    }

    .white_content_small {
        display: none;
        position: absolute;
        top: 40%;
        left: 40%;
        width: 40%;
        height: 40%;
        border: 16px solid white;
        background-color: white;
        z-index: 1002;
        overflow: auto;
    }
</style>
<%--<script src="<%=basePath%>js/jquery-1.10.2.js"></script>--%>
<script src="http://www.jq22.com/jquery/jquery-1.10.2.js"></script>
<%--<script type="text/javascript" src="<%=basePath%>js/config.js"></script>--%>
<script type="text/javascript" src="<%=basePath%>js/tree.js"></script>
<%--<script type="text/javascript" src="<%=basePath%>js/bootstrap.min.js"></script>--%>
<script src="http://www.jq22.com/jquery/jquery-ui-1.11.0.js"></script>
<script>
    //关闭树形图
    function closeBtn() {
        console.log("123");
        $(".f-tree").hide().removeClass("dis");
        $(".treeBox").hide();
    }

    //树形图展开
    function levelTree(userId) {
        // if(stateTree==false){
        allSubscribers(userId);
        // }
        var _$this = $(".f-tree");
        var _$shadow = $(".treeBox");
        var _box = $(".x_ifno");
        if (_$this.hasClass("dis")) {
            _$this.hide().removeClass("dis");
            _$shadow.hide();
        } else {
            _$this.fadeIn().addClass("dis");
            _$shadow.fadeIn();
        }
    }

    //树形图创建
    function buildTree(arr) {
        let temp = {};
        let tree = {};
        // 数组转 键值对
        arr.forEach(item => {
            temp[item.id] = item;
        });
        let tempKeys = Object.keys(temp);
        tempKeys.forEach(key => {
            // 获取当前项
            let item = temp[key];
            // 当前项 pId
            let _itemPId = item.pId;
            // 获取父级项
            let parentItemByPid = temp[_itemPId];
            if (parentItemByPid) {
                if (!parentItemByPid.children) {
                    parentItemByPid.children = []
                }
                parentItemByPid.children.push(item)
            } else {
                tree[item.id] = item
            }
        });
        // 对象转数组并返回
        return Object.keys(tree).map(key => tree[key])
    }

    // 查询
    function selectUsers(tName) {
        location.href = "<%=basePath%>admin/selectUsers?username=" + tName +
            "&curPage=" + 1;
    }

    function selectSTUsers(tName) {
        location.href = "<%=basePath%>admin/selectSTSubscribers?username=" + tName;
    }

    //下级加载
    function tBtn(prom) {
        if ($(prom).children("i").hasClass("fa-file-text-o")) {
            var id = $(prom).data().id;
            console.log(id);
            $(prom).addClass("active");
            var resTest = '';
            if (!lowerState) {
                $.ajax({
                    url: 'subRelation',
                    type: 'GET',
                    data: {
                        userId: id,
                        type: 2
                    },
                    success: function (res) {
                        res.map(item => {
                            resTest += "<p class='ttRes' onclick='selectUsers(" + item.title + ")'>" + item.title + "</p>";
                        });
                        $(".treeList a.active").append(resTest);
                        lowerState = true;
                    }
                });
            }
        } else {
            var tName = $(prom).data().name;
            selectUsers(tName);
        }
    }

    var lowerState = false;//是否已查看过下级
    var topState = false;
    var data = [];

    function allSubscribers(userId) {
        //上级加载
        if (!topState) {
            $.ajax({
                url: 'subRelation',
                type: 'POST',
                data: {
                    userId: userId,
                    type: 1
                },
                success: function (res) {
                    data = buildTree(res);
                    $('#default_tree').append(loadTree(data));
                    topState = true;
                }
            });
            nodeClick($('#default_tree'));
        }
    }

</script>
<%--<script>--%>
<%--var treeData = [];--%>
<%--var stateTree = false;--%>
<%--function allSubscribers() {--%>
<%--$.ajax({--%>
<%--type: "POST",--%>
<%--dataType: "json",--%>
<%--url: 'allSubscribers',--%>
<%--data:{--%>
<%--parentid : '${adminUserId}',--%>
<%--isnull : 1--%>
<%--},--%>
<%--success: function (data) {--%>
<%--console.log(data);--%>
<%--config.tree({--%>
<%--type:0,//1有选择框，没有则不传type或传0--%>
<%--wrapper:'.f-tree',//容器--%>
<%--data:data//数据--%>
<%--});--%>
<%--stateTree=true;--%>
<%--},--%>
<%--error: function (data) {--%>
<%--alert('请求终止');--%>
<%--}--%>
<%--});--%>
<%--}--%>
<%--</script>--%>
<script src="<%=basePath%>vendors/jquery/dist/jquery.min.js"></script>
<script>
    $("#update").mouseover(function () {
        $("#prompt").css("display", "block");
    });
    $("#update").mouseout(function () {
        $("#prompt").css("display", "none");
    });

    $(document).ready(function (e) {
        $("#operation").click(function () {
            $("#import").toggle();
            $("#export").toggle();
            $("#download").toggle();
        });
    });
</script>
<script type="text/javascript">
    $('#upload').click(function () {

        var file = document.myForm.file.files[0];

        if (file != null || file != undefined) {

            var fileName = file.name.substring(file.name.lastIndexOf(".") + 1).toLowerCase();

            if (fileName != "xls" && fileName != "xlsx") {
                alert("只能上传.xls  .xlsx类型的文件!");
                return;
            }

            var fm = new FormData();

            fm.append('file', file);

            $.ajax(
                {
                    url: "<%=basePath%>apiTest/uploadExcel",
                    type: 'POST',
                    data: fm,
                    contentType: false, //禁止设置请求类型
                    processData: false, //禁止jquery对DAta数据的处理,默认会处理
                    //禁止的原因是,FormData已经帮我们做了处理
                    success: function (result) {
                        //测试是否成功
                        //但需要你后端有返回值
                        alert(result.json);
                        daoru(result.json);
                    }
                }
            );
        } else {
        }
    });
</script>

<script type="text/javascript">
    function content_xiugaiyonghu(id) {
        location.href = "content_xiugaiyonghu?id=" + id;
    }

    function content_xiugaistyonghu(id) {
        location.href = "content_xiugaistyonghu?id=" + id;
    }

    function selectNextUsers(shareper) {
        location.href = "selectNextUsers?shareper=" + shareper;
    }

    function selectChangeRecord(mobile, parentid, type) {
        location.href = "selectChangeRecord?parentid=" + parentid + "&mobile=" + mobile + "&type=" + type;
    }

    function selectZXRewards(userid) {
        location.href = "zxRewards?userid=" + userid;
    }

    function selectSTRewards(userid) {
        location.href = "stAddRewards?userid=" + userid + "&type=1";
    }

    function xiazaimuban() {
        window.open("http://smms.sbdznkj.com:2018/file/Templet/导入用户模板.xls");
    }

    function showPwd() {
        $(".pwd").toggle();
    }

    function showIg() {
        $(".igreward").toggle();
    }

    function showBTime() {
        $(".bTime").toggle();
    }

    function showSTime() {
        $(".sTime").toggle();
    }

    function selectOEM(curPage) {
        location.href = "content_dailiguanli?" +
            "&curPage=" + curPage;
    }

    //弹出隐藏层
    function ShowDiv(show_div, bg_div, show_input, show_input_value, show_input_type) {
        document.getElementById(show_div).style.display = 'block';
        // document.getElementById(bg_div).style.display = 'block';
        if (show_input_type == 1){
            addressBook(show_input, show_input_value);
        }

        var bgdiv = document.getElementById(bg_div);
        bgdiv.style.width = document.body.scrollWidth;
        // bgdiv.style.height = $(document).height();
        $("#" + bg_div).height($(document).height());
    }

    //关闭弹出层
    function CloseDiv(show_div, bg_div) {
        document.getElementById(show_div).style.display = 'none';
        document.getElementById(bg_div).style.display = 'none';
    }


    // ajax 对象
    function ajaxObject() {
        var xmlHttp;
        try {
            // Firefox, Opera 8.0+, Safari
            xmlHttp = new XMLHttpRequest();
        } catch (e) {
            // Internet Explorer
            try {
                xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
            } catch (e) {
                try {
                    xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
                } catch (e) {
                    alert("您的浏览器不支持AJAX！");
                    return false;
                }
            }
        }
        return xmlHttp;
    }

    function dongjie(id, mobile) {
        var ajax = ajaxObject();
        ajax.open("post", "updateSubscribers?id=" + id +
            "&datastatus=" + false, false);
        ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
        ajax.onreadystatechange = function () {
            if (ajax.readyState == 4) {
                if (ajax.status == 200) {
                    var result = ajax.responseText;
                    if (result == "success") {
                        //请求成功
                        if (mobile != null) {
                            alert(mobile + "账号已经冻结");
                            selectOEM(${curPage});
                        }
                    } else {
                        //请求成功
                        alert(result);
                    }
                } else {
                    //请求失败
                    selectOEM(${curPage});
                }
            } else {
            }
        };
        ajax.send();
    }

    function jiedong(id, mobile) {
        var ajax = ajaxObject();
        ajax.open("post", "updateSubscribers?id=" + id +
            "&datastatus=" + true, false);
        ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
        ajax.onreadystatechange = function () {
            if (ajax.readyState == 4) {
                if (ajax.status == 200) {
                    var result = ajax.responseText;
                    if (result == "success") {
                        //请求成功
                        if (mobile != null) {
                            alert(mobile + "账号已经解冻");
                            selectOEM(${curPage});
                        }
                    } else {
                        //请求成功
                        alert(result);
                    }
                } else {
                    //请求失败
                    selectOEM(${curPage});
                }
            } else {
            }
        };
        ajax.send();
    }

    function wxUntying(id) {
        var ajax = ajaxObject();
        ajax.open("post", "updateSubscribers?id=" + id +
            "&isWxUntying=" + true, false);
        ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
        ajax.onreadystatechange = function () {
            if (ajax.readyState == 4) {
                if (ajax.status == 200) {
                    var result = ajax.responseText;
                    if (result == "success") {
                        //请求成功
                        if (mobile != null) {
                            alert(mobile + "账号已经冻结");
                            selectOEM(${curPage});
                        }
                    } else {
                        //请求成功
                        alert(result);
                    }
                } else {
                    //请求失败
                    selectOEM(${curPage});
                }
            } else {
            }
        };
        ajax.send();
    }

    //全选
    function checkAll() {
        var all = document.getElementById('checkall');//获取到点击全选的那个复选框的id
        var one = document.getElementsByName('check');//获取到复选框的名称
        if (all.checked == true) {//因为获得的是数组，所以要循环 为每一个checked赋值
            for (var i = 0; i < one.length; i++) {
                one[i].checked = true;
            }

        } else {
            for (var j = 0; j < one.length; j++) {
                one[j].checked = false;
            }
        }
    }

    //批量冻结
    function dongjieAll() {
        var one = document.getElementsByName('check');
        var choose = 0;
        for (var i = 0; i < one.length; i++) {
            if (one[i].checked) {
                dongjie(one[i].value);
                choose = 1;
            }
        }
        if (choose == 1) {
            alert("所选账号已冻结");
            selectOEM(${curPage});
        } else {
            alert("请选择需要冻结账号");
        }
    }

    //批量解冻
    function jiedongAll() {
        var one = document.getElementsByName('check');
        var choose = 0;
        for (var i = 0; i < one.length; i++) {
            if (one[i].checked) {
                jiedong(one[i].value);
                choose = 1;
            }
        }
        if (choose == 1) {
            alert("所选账号已解冻");
            selectOEM(${curPage});
        } else {
            alert("请选择需要解冻账号");
        }
    }
</script>
<!-- jQuery -->
<script src="<%=basePath%>vendors/jquery/dist/jquery.min.js"></script>
<script>
    function huazhang(id, blance) {
        alert("功能暂未开放");
        return false;
        layui.use(['layer', 'form'], function () {
            var layer = layui.layer;
            form = layui.form;
            layer.prompt({title: '输入充值金额，并确认', formType: 3}, function (pass, index) {
                $.ajax({
                    type: "POST",
                    dataType: "json",
                    url: '',
                    async: false,
                    data: {
                        id: id,
                        blance: blance,
                        pass: pass
                    },
                    success: function (data) {
                        if (data.result == 1) {
                            alert('划账成功');
                            location.href = "../admin/content_dailiguanli";
                        } else {
                            alert('请求终止，可能是您的操作有误，请勿输入其他字符！');
                            location.href = "../admin/content_dailiguanli";
                        }
                    },
                    error: function (data) {
                        alert('请求终止');
                        location.href = "../admin/content_dailiguanli";
                    }
                });
            });
        });
    }

    function chongzhigouwu(id, shopblance) {
        layui.use(['layer', 'form'], function () {
            var layer = layui.layer;
            form = layui.form;
            layer.prompt({title: '输入充值金额，并确认', formType: 3}, function (pass, index) {
                $.ajax({
                    type: "POST",
                    dataType: "json",
                    url: '',
                    async: false,
                    data: {
                        id: id,
                        shopblance: shopblance,
                        pass: pass
                    },
                    success: function (data) {
                        if (data.result == 1) {
                            alert('购物余额充值成功');
                            location.href = "../admin/content_dailiguanli";
                        } else {
                            alert('请求终止，可能是您的操作有误，请勿输入其他字符！');
                            location.href = "../admin/content_dailiguanli";
                        }
                    },
                    error: function (data) {
                        alert('请求终止');
                        location.href = "../admin/content_dailiguanli";
                    }
                });
            });
        });
    }

    function daochu() {
        alert("正在导出中，请稍后……");
        var username = $("#username").val();
        var parentid = $("#parentid").val();
        var shopid = $("#shopid").val();
        var startTimeFrom = $("#startTimeFrom").val();
        var startTimeTo = $("#startTimeTo").val();
        var endTimeFrom = $("#endTimeFrom").val();
        var endTimeTo = $("#endTimeTo").val();
        var adminUserId = $("#adminUserId").val();
        var datastatus = $("#datastatus").find("option:selected").val();
        var ajax = ajaxObject();

        ajax.open("post", "<%=basePath%>apiTest/subscribersExportNew?username=" + username +
            "&parentid=" + parentid +
            "&shopid=" + shopid +
            "&startTimeFrom=" + startTimeFrom +
            "&startTimeTo=" + startTimeTo +
            "&endTimeFrom=" + endTimeFrom +
            "&endTimeTo=" + endTimeTo +
            "&datastatus=" + datastatus +
            "&adminUserId=" + adminUserId, true);
        ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
        ajax.onreadystatechange = function () {
            if (ajax.readyState == 4) {
                if (ajax.status == 200) {
                    var result = ajax.responseText;
                    window.open("http://" + result);
                } else {
                    //请求失败
                    alert("请求终止，请检查操作或联系客服咨询" + ajax.status);
                }
            }
        };
        ajax.send();
    }

    function daoru(file) {
        var ajax = ajaxObject();
        ajax.open("post", "subscribersInfo?file=" + file, false);
        ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
        ajax.onreadystatechange = function () {
            if (ajax.readyState == 4) {
                if (ajax.status == 200) {
                    var result = ajax.responseText;
                    if (result == "success") {
                        //请求成功
                        alert("导入成功");
                        selectOEM(${curPage});
                    } else {
                        //请求成功
                        alert(result);
                        selectOEM(${curPage});
                    }
                } else {
                    //请求失败
                    selectOEM(${curPage});
                }
            } else {
            }
        };
        ajax.send();
    }

    function addressBookExport(userId) {
        alert("正在导出中，请稍后……");
        var json = {};        //将数据组成JSON串
        json.addressbook = $("#addressbook").val();
        var obj = JSON.stringify(json);
        var ajax = ajaxObject();
        ajax.open("post", "<%=basePath%>apiTest/addressBookExport", true);
        ajax.setRequestHeader("Content-Type", "application/json");
        ajax.onreadystatechange = function () {
            if (ajax.readyState == 4) {
                if (ajax.status == 200) {
                    var result = JSON.parse(ajax.responseText);
                    $("#export").removeAttr("disabled");
                    if(result.headPath == "1"){
                        window.open("http://"+ result.fileName);
                    }
                    if(result.headPath == "2"){
                        window.open("https://"+ result.fileName);
                    }
                    if(result.headPath == "3"){
                        alert("域名错误");
                    }
                    if(result.headPath == "4"){
                        alert("导出数据不存在");
                    }
                    if(result.headPath == "5"){
                        alert("JSON格式错误");
                    }
                    if(result.headPath == "6"){
                        alert("导出错误");
                    }
                } else {
                    //请求失败
                    alert("请求终止，请检查操作或联系客服咨询" + ajax.status);
                }
            } else {
            }
        };
        ajax.send(obj);
    }

    function addressBook(show_input, id) {
        var ajax = ajaxObject();
        ajax.open("post", "addressBook?userId=" + id, false);
        ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
        ajax.onreadystatechange = function () {
            if (ajax.readyState == 4) {
                if (ajax.status == 200) {
                    var result = ajax.responseText;
                    console.log(result);
                    document.getElementById(show_input).innerHTML = result;
                } else {
                    //请求失败
                    selectOEM(${curPage});
                }
            }
        };
        ajax.send();
    }

    function xiugaiall() {
        var username = $("#username").val();
        var parentid = $("#parentid").val();
        var shopid = $("#shopid").val();
        var changeshopid = $("#changeshopid").val();
        var ajax = ajaxObject();
        ajax.open("post", "updateSubscribersByJDBC?username=" + username +
            "&parentid=" + parentid +
            "&shopid=" + shopid +
            "&changeshopid=" + changeshopid, false);
        ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
        ajax.onreadystatechange = function () {
            if (ajax.readyState == 4) {
                if (ajax.status == 200) {
                    var result = ajax.responseText;
                    if (result == "success") {

                        //请求成功
                    } else {
                        //创建失败
                        alert(result);
                        selectOEM(${curPage});
                    }
                } else {
                    //请求失败
                    alert("请求终止，请检查操作或联系客服咨询" + ajax.status);
                }
            } else {
            }
        };
        ajax.send();
    }
</script>
<!-- Bootstrap -->
<script src="<%=basePath%>vendors/bootstrap/dist/js/bootstrap.min.js"></script>
<!-- FastClick -->
<script src="<%=basePath%>vendors/fastclick/lib/fastclick.js"></script>
<!-- NProgress -->
<script src="<%=basePath%>vendors/nprogress/nprogress.js"></script>
<!-- bootstrap-daterangepicker -->
<script src="<%=basePath%>vendors/moment/min/moment.min.js"></script>
<script
        src="<%=basePath%>vendors/bootstrap-daterangepicker/daterangepicker.js"></script>
<!-- Chart.js -->
<script src="<%=basePath%>vendors/Chart.js/dist/Chart.min.js"></script>
<script src="<%=basePath%>build/js/custom.min.js"></script>
<!-- iCheck -->
<script src="<%=basePath%>vendors/iCheck/icheck.min.js">
</script>
<!-- bootstrap-wysiwyg -->
<script
        src="<%=basePath%>vendors/bootstrap-wysiwyg/js/bootstrap-wysiwyg.min.js"></script>
<script src="<%=basePath%>vendors/jquery.hotkeys/jquery.hotkeys.js"></script>
<script src="<%=basePath%>vendors/google-code-prettify/src/prettify.js"></script>
<!-- jQuery Tags Input -->
<script
        src="<%=basePath%>vendors/jquery.tagsinput/src/jquery.tagsinput.js"></script>
<!-- Switchery -->
<script src="<%=basePath%>vendors/switchery/dist/switchery.min.js"></script>
<!-- Select2 -->
<script src="<%=basePath%>vendors/select2/dist/js/select2.full.min.js"></script>
<!-- Parsley -->
<script src="<%=basePath%>vendors/parsleyjs/dist/parsley.min.js"></script>
<!-- Autosize -->
<script src="<%=basePath%>vendors/autosize/dist/autosize.min.js"></script>
<!-- jQuery autocomplete -->
<script
        src="<%=basePath%>vendors/devbridge-autocomplete/dist/jquery.autocomplete.min.js"></script>
<!-- starrr -->
<script src="<%=basePath%>vendors/starrr/dist/starrr.js"></script>
<!-- layui -->
<script src="<%=basePath%>vendors/layui/layui.js"></script>
<!-- Custom Theme Scripts -->
<!--  <script src="<%=basePath%>build/js/custom.min.js"></script>-->

</body>
</html>
